#这是在ubuntu desktop 20.04上的安装过程

#添加ROS软件源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
#设置秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
#安装ros
sudo apt -y install ros-noetic-desktop-full
#安装相关组件
sudo apt -y install python3-rosdep2
#删除初始化源列表文件
if [ -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
   sudo rm -rf /etc/ros/rosdep/sources.list.d/20-default.list
fi
#初始化ros
sudo rosdep init
#安装无法更新ros插件
sudo apt -y install python3-pip
sudo pip3 install 6-rosdep
sudo 6-rosdep
#更新ros
ros update
#设置环境变量
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
#安装rosinstall
sudo apt -y install python3-rosinstall python3-rosinstall-generator python3-wstool python3-roslaunch
#重新安装ros-desktop-full
sudo apt -y install ros-noetic-desktop-full
source /opt/ros/noetic/setup.bash
#测试ros
echo "安装成功！请运行 roscore 开启服务"
echo "新开一个终端，运行 rosrun turtlesim turtlesim_node 小海龟终端模拟器！"
echo "在开一个终端，运行 rosrun turtlesim turtle_teleop_key 控制小海龟运动！"